/**	\author    coidgen 0.9.2
	\version    (1.0 build 16)
	\date      
	\brief     
*/

#ifndef __COID_CLIENT__logentmgr_h
#define __COID_CLIENT__logentmgr_h


#define CLIENT__logentmgr_h



#include "coid/coidclient.h"
#include "coid/comm/sync/mutex_reg.h"


extern const version COID_version_LogEntMgr_1_0;


#include "coid/svc/logstream.h"




namespace coid {


struct COID_TABLE_LogEntMgr_1_0;


///COID Log manager service
class LogEntMgr_client
{
	//NET_OPTIONS: direct nolog nolog_system_calls
private:
	COID_TABLE_LogEntMgr_1_0 * _me;
	COID_TABLE_LogEntMgr_1_0 * _vtbl;
	mutable comm_mutex_custom_reg<netstream, void*> _mx_reg;
	uint _conn_data;
	uint _timeout;
	charstr _addr;

	void set_connection_type( uint ct ) {_conn_data = ct;}
	void destroy_me();

public:
	LogEntMgr_client();
	~LogEntMgr_client();
	LogEntMgr_client( const LogEntMgr_client & c );
	LogEntMgr_client & operator = ( const LogEntMgr_client & c );

	opcd ping_server( const char * coid_address, uint coid_obj_id=UMAX32, uint coid_flags=ConnectFlags::xACCESS_MODE ) const;
	bool is_connected() const;
	opcd disconnect();
	const charstr& get_addr() const {return _addr;}
	comm_mutex_reg * get_mx() {return &_mx_reg;}
	opcd get_last_error() const;
	void set_last_error( opcd e );
	uint get_connection_type() const {return _conn_data;}
	opcd set_timeout( uint milliseconds );
	uint get_timeout() const {return _timeout;}
	void setup_stream( binstream& b, uint coid_flags, uint coid_obj_id ) const;
	bool setup_members( uint coid_stream_flags, netstream * bstream, binstream * bstream2=NULL, comm_mutex_reg * mx_reg=NULL );

	static const version & get_version() { return COID_version_LogEntMgr_1_0; }


public:
	// special functions
	opcd connect(  const charstr & name, const password & pwd, const char * coid_address=NULL, uint coid_flags=ConnectFlags::xACCESS_MODE );
	// special functions
	opcd connect_within(  comm_mutex_reg & coid_channel, const charstr & name, const password & pwd );
	opcd connect_shared( uint coid_obj_id, const char * coid_address=NULL, uint coid_flags=ConnectFlags::xACCESS_MODE );

	// client functions
	opcd read_log ( uints & ref, uints max, dynarray<logstream*> & list ) const;
	opcd add_filter ( const FILTER_ENTRY & flt );
	opcd delete_filter ( uint obj, uint fltn );
	opcd get_filters ( uint obj, uint fltn, dynarray<FILTER_ENTRY> & out ) const;
	opcd get_filter_ids ( uint obj, uint fltn, dynarray<uint> & out ) const;
	opcd get_log_upd ( uints * ref ) const;
	opcd get_tree_info ( dynarray<tree_info> & out, uints * ref ) const;
	opcd get_tree_info_changes ( uints & ref, dynarray<tree_info> & out ) const;
};

} // namespace coid


#endif	// ! __COID_CLIENT__logentmgr_h
